From 5ce761a2e61a484e76e74a0b058cbc6b7740c6ee Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 29 Apr 2005 14:56:37 +0000 Subject: [PATCH] Don't crash if the path does not point to a row in the model. (#300909, 2005-04-29 Matthias Clasen * gtk/gtkiconview.c (gtk_icon_view_select_path): Don't crash if the path does not point to a row in the model. (#300909, Mathias Hasselmann) --- ChangeLog | 4 ++++ ChangeLog.pre-2-10 | 4 ++++ ChangeLog.pre-2-8 | 4 ++++ gtk/gtkiconview.c | 14 ++++++-------- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95ca30919f..931f0cbe27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2005-04-29 Matthias Clasen + * gtk/gtkiconview.c (gtk_icon_view_select_path): Don't crash + if the path does not point to a row in the model. (#300909, + Mathias Hasselmann) + * tests/testtext.c: Add some more attribute tests. * gtk/gtktexttag.c (gtk_text_tag_class_init): Correct the documentation diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 95ca30919f..931f0cbe27 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,9 @@ 2005-04-29 Matthias Clasen + * gtk/gtkiconview.c (gtk_icon_view_select_path): Don't crash + if the path does not point to a row in the model. (#300909, + Mathias Hasselmann) + * tests/testtext.c: Add some more attribute tests. * gtk/gtktexttag.c (gtk_text_tag_class_init): Correct the documentation diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 95ca30919f..931f0cbe27 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,9 @@ 2005-04-29 Matthias Clasen + * gtk/gtkiconview.c (gtk_icon_view_select_path): Don't crash + if the path does not point to a row in the model. (#300909, + Mathias Hasselmann) + * tests/testtext.c: Add some more attribute tests. * gtk/gtktexttag.c (gtk_text_tag_class_init): Correct the documentation diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 56369f5e19..d692aa5353 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -3480,19 +3480,17 @@ void gtk_icon_view_select_path (GtkIconView *icon_view, GtkTreePath *path) { - GtkIconViewItem *item; - + GList *l; + g_return_if_fail (GTK_IS_ICON_VIEW (icon_view)); g_return_if_fail (icon_view->priv->model != NULL); g_return_if_fail (path != NULL); - item = g_list_nth (icon_view->priv->items, - gtk_tree_path_get_indices(path)[0])->data; + l = g_list_nth (icon_view->priv->items, + gtk_tree_path_get_indices(path)[0]); - if (!item) - return; - - gtk_icon_view_select_item (icon_view, item); + if (l != NULL) + gtk_icon_view_select_item (icon_view, l->data); } /** -- 2.30.2